﻿<UserControl x:Class="Presentation.DashboardView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Style="{StaticResource CommonViewStyle}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        
        <ItemsControl x:Name="SignalementsList"
                    Style="{StaticResource VerticallMetroItemsControlStyle}"
                    ItemsSource="{Binding SignalementsCollection}" 
                    Margin="10,10,5,10" 
                    BorderThickness="0" Padding="0,0,5,0"
                    BorderBrush="White">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Border x:Name="Bd" Margin="2" Padding="10">
                        <Border.Background>
                            <SolidColorBrush Color="#FF00BF" Opacity="0.3"></SolidColorBrush>
                        </Border.Background>
                        <Grid>
                            <Grid.Resources>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="FontSize" Value="16"></Setter>
                                    <Setter Property="FontFamily" Value="Segoe UI"></Setter>
                                    <Setter Property="Foreground" Value="White"></Setter>
                                </Style>
                            </Grid.Resources>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition></ColumnDefinition>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="0"
                                       FontWeight="SemiBold"
                                       Text="{Binding Path=MaxRepairDate, StringFormat=Date max de dépannage : {0:dd/MM/yyyy}}"></TextBlock>

                            <TextBlock Grid.Row="1" 
                                       Text="{Binding Path=BeginDate, StringFormat=Date de constat : {0:dd/MM/yyyy}}"></TextBlock>

                            <TextBlock Grid.Row="2"
                                       Text="{Binding ObjetPatrimonial.Label, StringFormat=Objet Patrimonial : {0}}"></TextBlock>
                            <TextBlock Grid.Row="3"
                                       Text="{Binding Panne.Label, StringFormat=Panne : {0}}"></TextBlock>
                            <Border Grid.RowSpan="4" Grid.Column="1" 
                                    VerticalAlignment="Center" 
                                    HorizontalAlignment="Right"
                                    Padding="5,3,5,3"
                                    BorderBrush="White" BorderThickness="2" 
                                    CornerRadius="5" Background="OrangeRed"
                                    Visibility="{Binding Path=IsUrgent, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <TextBlock FontFamily="Segoe UI" FontSize="16" FontWeight="SemiBold" Text="Urgent"></TextBlock>
                            </Border>

                        </Grid>
                    </Border>
                    <DataTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="Bd">
                            <Trigger.Setters>
                                <Setter TargetName="Bd" Property="Background">
                                    <Setter.Value>
                                        <SolidColorBrush Color="#FF00BF"
                                                         Opacity="0.8"></SolidColorBrush>
                                    </Setter.Value>
                                </Setter>
                            </Trigger.Setters>
                        </Trigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        <Border x:Name="waitIndicator"                
                Padding="3"
                VerticalAlignment="Center"
                Visibility="{Binding Path=IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}">
            <StackPanel HorizontalAlignment="Center">
                <TextBlock Text="Chargement en cours ..."
                           FontSize="12"
                           Foreground="White"
                           FontFamily="Segoe UI"></TextBlock>
                <ProgressBar Height="10"
                             Margin="0,3,0,0"
                             IsIndeterminate="True"></ProgressBar>
            </StackPanel>
        </Border>

        <Border Grid.Column="1"
                Margin="5,10,5,5"
                Padding="5"
                VerticalAlignment="Top">
            <Button Content="Créer un signalement"
                    Command="{Binding SignalerPanneCommand}"
                    HorizontalAlignment="Left"></Button>
        </Border>
    </Grid>
</UserControl>
